//
//  ViewController.m
//  Zoo
//
//  Created by zhiyou on 16-5-26.
//  Copyright (c) 2016年 ZY. All rights reserved.
//

#import "ViewController.h"
#import <AudioToolbox/AudioToolbox.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSLog(@"123456789");
    
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    [self playSound:@"雨一直下.mp3"];

}

- (void)playSound:(NSString *)name {
    NSString *file = [[NSBundle mainBundle] pathForResource:name ofType:nil];
    NSURL *url = [NSURL fileURLWithPath:file];
    
    SystemSoundID soundID = 0;
    
    AudioServicesCreateSystemSoundID((__bridge CFURLRef)(url), &soundID);
    AudioServicesAddSystemSoundCompletion(soundID, NULL, NULL,soundCompleteCallback , NULL);
    AudioServicesPlaySystemSound(soundID);



}

void soundCompleteCallback(SystemSoundID soundID,void * clientData){
    NSLog(@"播放完成...");
}


@end
